﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using 海漫思考核.DAL;

namespace 海漫思考核.BLL
{
    public class UserBLL
    {
        /// <summary>
        /// 查询用户是否存在
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool UserExists(User user)
        {
            using (NoveEntities ef = new NoveEntities())
            {
                var newuser = ef.User.Where(a => a.Uname == user.Uname && a.Upwd == user.Upwd).FirstOrDefault();
                return newuser != null;
            }
        }
        /// <summary>
        /// 按找ID查询用户
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public static User SelectByUid(int uid)
        {
            using (NoveEntities ef = new NoveEntities())
            {
                return ef.User.Where(a => a.Uid == uid).FirstOrDefault();
            }
        }
        /// <summary>
        /// 按照用户名查询用户
        /// </summary>
        /// <param name="uname"></param>
        /// <returns></returns>
        public static User SelectByUname(string uname)
        {
            using (NoveEntities ef = new NoveEntities())
            {
                return ef.User.Where(a => a.Uname == uname).FirstOrDefault();
            }
        }
    }
}